home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / MUI / MCC_NList / Developer / C / Examples / NList-Demo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-30  |  29.0 KB  |  751 lines

  1.  
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <dos/dos.h>
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8. #include <exec/ports.h>
  9. #include <exec/io.h>
  10. #include <libraries/dos.h>
  11. #include <libraries/dosextens.h>
  12. #include <libraries/gadtools.h>
  13. #include <libraries/asl.h>
  14. #include <libraries/mui.h>
  15. #include <devices/clipboard.h>
  16. #include <workbench/workbench.h>
  17. #include <intuition/intuition.h>
  18. #include <intuition/classusr.h>
  19. #include <graphics/gfxmacros.h>
  20.  
  21. #ifdef __GNUC__
  22. #include <proto/alib.h>
  23. #include <proto/exec.h>
  24. #include <proto/dos.h>
  25. #include <proto/gadtools.h>
  26. #include <proto/asl.h>
  27. #include <clib/muimaster_protos.h>
  28. #endif
  29.  
  30. #ifdef __SASC
  31. #include <clib/alib_protos.h>
  32. #include <clib/exec_protos.h>
  33. #include <clib/dos_protos.h>
  34. #include <clib/icon_protos.h>
  35. #include <clib/graphics_protos.h>
  36. #include <clib/intuition_protos.h>
  37. #include <clib/gadtools_protos.h>
  38. #include <clib/utility_protos.h>
  39. #include <clib/asl_protos.h>
  40. #define REG(x) register __ ## x
  41. #define ASM    __asm
  42. #define SAVEDS __saveds
  43. #include <pragmas/exec_sysbase_pragmas.h>
  44. #include <pragmas/dos_pragmas.h>
  45. #include <pragmas/icon_pragmas.h>
  46. #include <pragmas/graphics_pragmas.h>
  47. #include <pragmas/intuition_pragmas.h>
  48. #include <pragmas/gadtools_pragmas.h>
  49. #include <pragmas/utility_pragmas.h>
  50. #include <pragmas/asl_pragmas.h>
  51. #include <pragmas/muimaster_pragmas.h>
  52. extern struct Library *SysBase,*IntuitionBase,*UtilityBase,*GfxBase,*DOSBase,*IconBase;
  53. ULONG __stack = 16384;
  54. int CXBRK(void) { return(0); }
  55. int _CXBRK(void) { return(0); }
  56. void chkabort(void) {}
  57. #endif
  58.  
  59. struct Library *MUIMasterBase;
  60.  
  61. #include <MUI/NListview_mcc.h>
  62. #include <MUI/NFloattext_mcc.h>
  63.  
  64. #include <proto/muimaster.h>
  65.  
  66.  
  67. #include "NList-Demo2.h"
  68. #include "NList-Demo3.h"
  69.  
  70.  
  71. /* *********************************************** */
  72.  
  73.  
  74. static APTR APP_Main,
  75.             WIN_Main,
  76.             WIN_2,
  77.             BM_img,
  78.             BM_img2,
  79.             BT_TitleOn,
  80.             BT_TitleOff,
  81.             BT_NoMulti,
  82.             BT_Multidef,
  83.             BT_Multi,
  84.             BT_AllMulti,
  85.             BT_InputOn,
  86.             BT_InputOff,
  87.             BT_Sort,
  88.             BT_DragSortOn,
  89.             BT_DragSortOff,
  90.             BT_SelLine,
  91.             BT_SelChar,
  92.             BT_OpenWin2,
  93.             BT_RemAct,
  94.             BT_RemSel,
  95.             BT_Clear,
  96.             BT_Add,
  97.             LV_Text,
  98.             LI_Text,
  99.             LV_Text2,
  100.             LI_Text2,
  101.             PR_Horiz,
  102.             ST_string;
  103.  
  104.  
  105. /* ************ IMG definitions ************** */
  106.  
  107. const ULONG list_colors[24] =
  108. {
  109. 0xadadadad,0xadadadad,0xadadadad,
  110. 0x7b7b7b7b,0x7b7b7b7b,0x7b7b7b7b,
  111. 0x3b3b3b3b,0x67676767,0xa2a2a2a2,
  112. 0xadadadad,0xadadadad,0xadadadad,
  113. 0xadadadad,0xadadadad,0xadadadad,
  114. 0xadadadad,0xadadadad,0xadadadad,
  115. 0xffffffff,0xffffffff,0xffffffff,
  116. 0x00000000,0x00000000,0x00000000,
  117. };
  118.  
  119. const UBYTE list_body[168] = {
  120. 0x00,0x00,0x44,0x00,0xff,0xff,0xb8,0x00,0xff,0xff,0xb8,0x00,0x00,0x00,0x00,
  121. 0x00,0x80,0x00,0x64,0x00,0xff,0xff,0xb8,0x00,0x3b,0xb8,0x46,0x00,0x80,0x00,
  122. 0x64,0x00,0xc4,0x47,0xfc,0x00,0x00,0x00,0x46,0x00,0x80,0x00,0x64,0x00,0xff,
  123. 0xff,0xfc,0x00,0x36,0xd8,0x46,0x00,0x80,0x00,0x64,0x00,0xc9,0x27,0xfc,0x00,
  124. 0x00,0x00,0x46,0x00,0x80,0x00,0x64,0x00,0xff,0xff,0xfc,0x00,0x3d,0xe8,0x6e,
  125. 0x00,0x80,0x00,0x5c,0x00,0xc2,0x17,0xcc,0x00,0x00,0x00,0x46,0x00,0x80,0x00,
  126. 0x78,0x00,0xff,0xff,0xf8,0x00,0x00,0x00,0x40,0x00,0x80,0x00,0x64,0x00,0xff,
  127. 0xff,0xf8,0x00,0xbf,0xff,0xee,0x00,0x7f,0xff,0xdc,0x00,0x3f,0xff,0xcc,0x00,
  128. 0x00,0x44,0x46,0x00,0xff,0xbb,0xb8,0x00,0xff,0xbb,0xb8,0x00,0x00,0x00,0x00,
  129. 0x00,0x80,0x66,0x64,0x00,0xff,0xbb,0xb8,0x00,0xbf,0xee,0xee,0x00,0x7f,0xdd,
  130. 0xdc,0x00,0x3f,0xcc,0xcc,0x00,0x3f,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,
  131. 0x00,0x00,0x00, };
  132.  
  133. #define LIST_WIDTH        23
  134. #define LIST_HEIGHT       14
  135. #define LIST_DEPTH         3
  136. #define LIST_COMPRESSION   0
  137. #define LIST_MASKING       2
  138.  
  139. #define IMG \
  140.   BodychunkObject,\
  141.     MUIA_FixWidth             , LIST_WIDTH ,\
  142.     MUIA_FixHeight            , LIST_HEIGHT,\
  143.     MUIA_Bitmap_Width         , LIST_WIDTH ,\
  144.     MUIA_Bitmap_Height        , LIST_HEIGHT,\
  145.     MUIA_Bodychunk_Depth      , LIST_DEPTH ,\
  146.     MUIA_Bodychunk_Body       , (UBYTE *) list_body,\
  147.     MUIA_Bodychunk_Compression, LIST_COMPRESSION,\
  148.     MUIA_Bodychunk_Masking    , LIST_MASKING,\
  149.     MUIA_Bitmap_SourceColors  , (ULONG *) list_colors,\
  150.     MUIA_Bitmap_Transparent   , 0,\
  151.   End
  152.  
  153.  
  154. /* ************ IMG2 definitions ************** */
  155.  
  156. const ULONG list2_colors[24] =
  157. {
  158. 0xabababab,0xadadadad,0xc5c5c5c5,
  159. 0x7b7b7b7b,0x7b7b7b7b,0x7b7b7b7b,
  160. 0x3b3b3b3b,0x67676767,0xa2a2a2a2,
  161. 0x00000000,0x00000000,0x00000000,
  162. 0xffffffff,0xa9a9a9a9,0x97979797,
  163. 0xffffffff,0xffffffff,0xffffffff,
  164. 0x00000000,0x00000000,0x00000000,
  165. 0xadadadad,0xadadadad,0xadadadad,
  166. };
  167.  
  168. const UBYTE list2_body[156] = {
  169. 0x04,0x00,0x04,0x00,0x78,0x00,0x08,0x00,0x30,0x00,0x08,0x00,0x79,0x00,0x02,
  170. 0x00,0x8e,0x00,0x1c,0x00,0x3e,0x00,0x1c,0x00,0x7e,0x10,0x04,0x00,0x83,0xe0,
  171. 0x08,0x00,0xfe,0x80,0x08,0x00,0x45,0x02,0x00,0x00,0x85,0x9c,0x00,0x00,0xff,
  172. 0x70,0x00,0x00,0x7e,0x1c,0x80,0x00,0xc1,0x3b,0x78,0x00,0xfe,0xf9,0x30,0x00,
  173. 0x00,0x2f,0xb0,0x00,0xff,0x60,0x4c,0x00,0x7e,0xbf,0x48,0x00,0x7c,0x27,0x68,
  174. 0x00,0x03,0xc1,0xa4,0x00,0x01,0x7f,0xb4,0x00,0x01,0x1a,0xd8,0x00,0x03,0xe3,
  175. 0xa4,0x00,0x01,0xbf,0xac,0x00,0x00,0x6c,0xaa,0x00,0x04,0x99,0xd4,0x00,0x03,
  176. 0x97,0xfc,0x00,0x01,0x76,0x5a,0x00,0x38,0x8d,0xec,0x00,0x1e,0x8b,0x7c,0x00,
  177. 0x02,0xeb,0x72,0x00,0x0d,0x04,0xfc,0x00,0x09,0x06,0xf8,0x00,0x01,0x84,0x06,
  178. 0x00,0x0e,0x02,0xf8,0x00,0x06,0x01,0xb0,0x00,0x00,0x03,0xfc,0x00,0x00,0x00,
  179. 0x00,0x00,0x00,0x00,0x00,0x00, };
  180.  
  181. #define LIST2_WIDTH        23
  182. #define LIST2_HEIGHT       13
  183. #define LIST2_DEPTH         3
  184. #define LIST2_COMPRESSION   0
  185. #define LIST2_MASKING       2
  186.  
  187. #define IMG2 \
  188.   BodychunkObject,\
  189.     MUIA_FixWidth             , LIST2_WIDTH ,\
  190.     MUIA_FixHeight            , LIST2_HEIGHT,\
  191.     MUIA_Bitmap_Width         , LIST2_WIDTH ,\
  192.     MUIA_Bitmap_Height        , LIST2_HEIGHT,\
  193.     MUIA_Bodychunk_Depth      , LIST2_DEPTH ,\
  194.     MUIA_Bodychunk_Body       , (UBYTE *) list2_body,\
  195.     MUIA_Bodychunk_Compression, LIST2_COMPRESSION,\
  196.     MUIA_Bodychunk_Masking    , LIST2_MASKING,\
  197.     MUIA_Bitmap_SourceColors  , (ULONG *) list2_colors,\
  198.     MUIA_Bitmap_Transparent   , 0,\
  199.   End
  200.  
  201.  
  202. /* *********************************************** */
  203.  
  204.  
  205. #define ID_LIST2_ACTIVE 1
  206.  
  207. #define NL "\n"
  208. #define NL2 " "
  209.  
  210.  
  211. /* *********************************************** */
  212.  
  213. char MainTextString2[] =
  214. {
  215.   "This new list/listview custom class has its own backgrounds" NL2
  216.   "and pens setables from mui prefs with NListviews.mcp !" NL2
  217.   "It doesn't use the same way to handle multiselection" NL2
  218.   "with mouse and keys than standard List/Listview." NL
  219.   "\033C" NL
  220.   "You can horizontally scroll with cursor keys," NL2
  221.   "or going on the right and left of the list" NL2
  222.   "while selecting with the mouse." NL2
  223.   "(When there is no immediate draggin stuff active...)" NL2
  224.   "Try just clicking on the left/right borders !" NL
  225.   "\033C" NL
  226.   "\033r\033uGive some feedback about it ! :-)" NL
  227.   "\033r\033b(masson@iut-soph.unice.fr)"
  228. };
  229.  
  230. /* *********************************************** */
  231. char MainTextString[] =
  232. {
  233.   "\033cNList.mcc \033o[0] NListview.mcc \033o[1] NListviews.mcp" NL
  234.   "\033E\033t\033c\033o[2@1]" NL
  235.   "\033c\033nThis new list/listview custom class has its own backgrounds" NL
  236.   "\033cand pens setables from mui prefs with NListviews.mcp !" NL
  237.   "\033E\033t[M7]\033c\033o[3@2]" NL
  238.   "" NL
  239.   "\033cIt doesn't use the same way to handle multiselection" NL
  240.   "\033cwith mouse and keys than standard List/Listview." NL
  241.   "" NL
  242.   "\033cYou can horizontally scroll with cursor keys," NL
  243.   "\033cor going on the right and left of the list" NL
  244.   "\033cwhile selecting with the mouse." NL
  245.   "\033c(When there is no immediate draggin stuff active...)" NL
  246.   "\033cTry just clicking on the left/right borders !" NL
  247.   "" NL
  248.   "\033r\033uGive some feedback about it ! :-)" NL
  249.   "\033r\033b(masson@iut-soph.unice.fr)"
  250. };
  251.  
  252. /* *********************************************** */
  253.  
  254. char *MainTextArray[] =
  255. {
  256.   "\033c\033nThis new list/listview custom class has its own backgrounds",
  257.   "\033cand pens setables from mui prefs with NListviews.mcp !",
  258.   " ",
  259.   "\033cIt doesn't use the same way to handle multiselection",
  260.   "\033cwith mouse and keys than standard List/Listview.",
  261.   " ",
  262.   "\033cYou can horizontally scroll with cursor keys,",
  263.   "\033cor going on the right and left of the list",
  264.   "\033cwhile selecting with the mouse.",
  265.   "\033c(When there is no draggin stuff active...)",
  266.   "\033cTry just clicking on the left/right borders !",
  267.   "",
  268.   "\033r\033uGive some feedback about it ! :-)",
  269.   "\033r\033b(masson@iut-soph.unice.fr)",
  270.   "",
  271.   "",
  272.   "",
  273.   "You can push column titles as real buttons...",
  274.   "",
  275.   "You can drag column separator bar in",
  276.   "the title to adjust column width...",
  277.   "(or in upper half of first entry if title is off)",
  278.   "",
  279.   "If, while dragging the bar, you press the",
  280.   "menu button, the width of the column will",
  281.   "come back to its default...",
  282.   "",
  283.   "You can click on columns title to sort the list contents.",
  284.   "You can shift-click (or other qualifier if you modify the",
  285.   "default one) to add a secondary sorting column.",
  286.   "",
  287.   "",
  288.   "",
  289.   "\033cF2 to copy selected lines to printer",
  290.   "\033cF3 to copy all lines to file RAM:tmp.txt",
  291.   "",
  292.   "\033cF4 to copy selected lines to clipboard 0.",
  293.   "\033cF5 to copy active line to clipboard 0.",
  294.   "\033cF6 to copy all lines to clipboard 0.",
  295.   "",
  296.   "\033cThe classic RightAmiga+C to copy selected",
  297.   "\033clines to clipboard 0 is made builtin.",
  298.   " ",
  299.   " ",
  300.   "\033cYou can sort the entries by dragging.",
  301.   "\033cYou start a drag using one of the qualifier",
  302.   "\033ckeys which are set in prefs,",
  303.   "\033cor going on the left and right of entries.",
  304.   "",
  305.   "",
  306.   "Example of horizontal line in top of entry",
  307.   "\033TExample of horizontal line in top of entry",
  308.   "Example of horizontal line in top of entry",
  309.   "",
  310.   "Examples of horizontal line and thick line centered on entry",
  311.   "\033C",
  312.   "\033C\033t",
  313.   "\033C\033t[I7]",
  314.   "\033C\033t[M7]",
  315.   "\033C\033t[-5]",
  316.   "\033C\033t[N]",
  317.   "\033C\033t[NI3]",
  318.   "\033C\033t[NM7]",
  319.   "\033C\033t[N-5]",
  320.   "Examples of horizontal line and thick line centered on entry",
  321.   "",
  322.   "Example of horizontal line in bottom of entry",
  323.   "\033BExample of horizontal line in bottom of entry",
  324.   "Example of horizontal line in bottom of entry",
  325.   "",
  326.   "Examples of horizontal line centered on entry visible on left and rigth only",
  327.   "\033c\033EExample of left-right horizontal line",
  328.   "\033ESame, but left aligned",
  329.   "\033r\033ESame, but right aligned",
  330.   "\033t\033c\033ELeft-right horizontal thick line",
  331.   "\033t[N]\033c\033ELeft-right horizontal thick line",
  332.   "Examples of horizontal line centered on entry visible on left and rigth only",
  333.   "",
  334.   "",
  335.   "\033E\033cExamples of bitmap images :",
  336.   "\033c\033o[0]  \033o[1]",
  337.   "which can be used without subclassing the NList class.",
  338.   "",
  339.   "\033E\033cExamples of custom object images : ",
  340.   "\033o[2;9d51ffff;1]  (default width/special 1)",
  341.   "\033o[2;9d51ffff;0,24] (24 pixel width/special 0)",
  342.   "\033o[2;9d51ffff;1,48] (48 pixel width/special 1)",
  343.   "\033o[2;9d51ffff;0,96] (96 pixel width/special 0)",
  344.   "",
  345.   "\033E\033cExamples of custom object images : ",
  346.   "\033o[2;9d51ffff;8,30]  (default width/special 8)",
  347.   "\033o[2;9d51ffff;6,40]  (default width/special 6)",
  348.   "\033o[2;9d51ffff;7,40] (40 pixel width/special 7)",
  349.   "\033o[2;9d51ffff;4,50] (50 pixel width/special 4)",
  350.   "\033o[2;9d51ffff;5,50] (50 pixel width/special 5)",
  351.   "\033o[2;9d51ffff;2,30] (30 pixel width/special 2)",
  352.   "\033o[2;9d51ffff;3,30] (30 pixel width/special 3)",
  353.   "",
  354.   "\033E\033cExamples of direct ImageSpec :",
  355.   "kmel/kmel_arrowdown.image :    \033I[3:kmel/kmel_arrowdown.image]",
  356.   "WD/11pt/ArrowLeft.mf0 :    \033I[3:WD/11pt/ArrowLeft.mf0]",
  357.   "",
  358.   "\033C",
  359.   "",
  360.   "ww\tTabulation test",
  361.   "w\tTabulation test",
  362.   "\033cww\tTabulation test",
  363.   "\033cw\tTabulation test",
  364.   "\033rww\tTabulation test",
  365.   "\033rw\tTabulation test",
  366.   "",
  367.   "",
  368.   "long line for FULLAUTO horizontal scroller test, long line for FullAuto horizontal scroller test, long line for FULLAUTO horizontal scroller test.",
  369.   "",
  370.   "0 just a little \033bline to test\033n stuffs",
  371.   "1 just a little \033bline to test\033n stuffs",
  372.   "2 just a little \033bline to test\033n stuffs",
  373.   "3 just a little \033bline to test\033n stuffs",
  374.   "\033c4 just a little \033uline to test\033n (center)",
  375.   "\033c5 just a little \033uline to test\033n (center)",
  376.   "\033c6 just a little \033uline to test\033n (center)",
  377.   "\033r7 just a little \033uline to test\033n (right)",
  378.   "\033r8 just a little \033uline to test\033n (right)",
  379.   "\033r9 just a little \033uline to test\033n (right)",
  380.   "10 just a little line to test stuffs and bugs",
  381.   "11 just a little line to test stuffs and bugs",
  382.   "12 just a little line to test stuffs and bugs",
  383.   "13 just a little line to test stuffs and bugs",
  384.   "14 just a little line to test stuffs and bugs",
  385.   "15 just a little \033iline to test stuffs\033n and bugs",
  386.   "16 just a little line to test stuffs and bugs",
  387.   "17 just a little line to test stuffs and bugs",
  388.   "18 just a little line to test stuffs and bugs",
  389.   "19 just a little line to test stuffs and bugs",
  390.   "\033c20 just a little line to test stuffs and bugs (center)",
  391.   "\033c21 just a little line to test stuffs and bugs (center)",
  392.   "\033c22 just a little line to test stuffs and bugs (center)",
  393.   "\033c23 just a little line to test stuffs and bugs (center)",
  394.   "24 just a little line to test stuffs and bugs, just a little line",
  395.   "25 just a little line to test stuffs and bugs, just a little line",
  396.   "\033r26 just a little line to test stuffs and bugs (right)",
  397.   "\033r27 just a little line to test stuffs and bugs (right)",
  398.   "\033r28 just a little line to test stuffs and bugs (right)",
  399.   "\033r29 just a little line to test stuffs and bugs (right)",
  400.   "30 just a little line to test stuffs and bugs, just a little line to test",
  401.   "31 just a little line to test stuffs and bugs, just a little line to test",
  402.   "32 \0332just a little line to test stuffs and bugs, just a little line to test",
  403.   "33 \0333just a little line to test stuffs and bugs, just a little line to test",
  404.   "34 \0334just a little line to test stuffs and bugs, just a little line to test",
  405.   "35 \0335just a little line to test stuffs and bugs, just a little line to test",
  406.   "36 \0336just a little line to test stuffs and bugs, just a little line to test",
  407.   "37 \0337just a little line to test stuffs and bugs, just a little line to test",
  408.   "38 \0338just a little line to test stuffs and bugs, just a little line to test",
  409.   "39 \0339just a little line to test stuffs and bugs, just a little line to test",
  410.   "40 \033P[]just a little line to test stuffs and bugs, just a little line to test stuffs ",
  411.   "41 \033P[1]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
  412.   "42 \033P[2]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
  413.   "43 \033P[-1]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
  414.   "44 \033P[-3]just a little line to test\033P[] stuffs and bugs, just a little line to test stuffs ",
  415.   "45 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  416.   "46 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  417.   "47 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  418.   "48 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  419.   "49 just a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  420.   "50 \033ijust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  421.   "51 \033ujust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  422.   "52 \033bjust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  423.   "53 \033i\033ujust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  424.   "54 \033i\033bjust a little line to test stuffs and bugs, just a little line to test stuffs and bugs",
  425.   "55 \033b\033ujust a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
  426.   "56 \033i\033b\033ujust a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
  427.   "57 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
  428.   "58 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
  429.   "59 just a little line to test stuffs and bugs, just a little line to test, just a little line to test, just a little line to test",
  430.   " ",
  431.   " ",
  432.   "\033c\033uI find it \033bnice\033n  :-)",
  433.   NULL
  434. };
  435.  
  436. /* *********************************************** */
  437.  
  438.  
  439. static VOID fail(APTR APP_Main,char *str)
  440. {
  441.   if (APP_Main)
  442.     MUI_DisposeObject(APP_Main);
  443.   NLI_Delete();
  444.   if (MUIMasterBase)
  445.     CloseLibrary(MUIMasterBase);
  446.   if (str)
  447.   { puts(str);
  448.     exit(20);
  449.   }
  450.   exit(0);
  451. }
  452.  
  453.  
  454. static VOID init(VOID)
  455. {
  456.   APP_Main = NULL;
  457.   if (!(MUIMasterBase = (struct Library *) OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN-1)))
  458.     fail(NULL,"Failed to open "MUIMASTER_NAME".");
  459.   if (!NLI_Create())
  460.     fail(NULL,"Failed to create NLI class.");
  461. }
  462.  
  463.  
  464. /* *********************************************** */
  465.  
  466.  
  467. int main(int argc,char *argv[])
  468. {
  469.   LONG win_opened;
  470.   LONG result;
  471.  
  472.   init();
  473.  
  474.   APP_Main = ApplicationObject,
  475.     MUIA_Application_Title      , "NList-Demo",
  476.     MUIA_Application_Version    , "$VER: NList-Demo 0.8 (" __DATE__ ")",
  477.     MUIA_Application_Copyright  , "Written by Gilles Masson, 1996-1998",
  478.     MUIA_Application_Author     , "Gilles Masson",
  479.     MUIA_Application_Description, "NList-Demo",
  480.     MUIA_Application_Base       , "NList-Demo",
  481.  
  482.     SubWindow, WIN_Main = WindowObject,
  483.       MUIA_Window_Title, "NList-Demo 1996-1998",
  484.       MUIA_Window_ID   , MAKE_ID('T','W','I','N'),
  485.       WindowContents, VGroup,
  486.         Child, HGroup,
  487.           Child, BT_InputOn = SimpleButtonCycle("InputOn"),
  488.           Child, BT_InputOff = SimpleButtonCycle("InputOff"),
  489.           Child, BT_SelLine = SimpleButtonCycle("SelLine"),
  490.           Child, BT_SelChar = SimpleButtonCycle("SelChar"),
  491.           Child, BT_Clear = SimpleButtonCycle("Clear"),
  492.           Child, BT_Add = SimpleButtonCycle("Add"),
  493.         End,
  494.         Child, HGroup,
  495.           Child, BT_NoMulti = SimpleButtonCycle("NoMulti"),
  496.           Child, BT_Multidef = SimpleButtonCycle("Def"),
  497.           Child, BT_Multi = SimpleButtonCycle("Multi"),
  498.           Child, BT_AllMulti = SimpleButtonCycle("AllMulti"),
  499.           Child, BM_img = IMG,
  500.           Child, BT_RemAct = SimpleButtonCycle("RemAct"),
  501.           Child, BT_RemSel = SimpleButtonCycle("RemSel"),
  502.         End,
  503.         Child, HGroup,
  504.           Child, BT_DragSortOn = SimpleButtonCycle("DragSortOn"),
  505.           Child, BT_DragSortOff = SimpleButtonCycle("DragSortOff"),
  506.           Child, BM_img2 = IMG2,
  507.           Child, BT_TitleOn = SimpleButtonCycle("TitleOn"),
  508.           Child, BT_TitleOff = SimpleButtonCycle("TitleOff"),
  509.           Child, BT_Sort = SimpleButtonCycle("Sort"),
  510.           Child, BT_OpenWin2 = SimpleButtonCycle("Win2"),
  511.         End,
  512.         Child, LV_Text = NListviewObject,
  513.           MUIA_CycleChain, 1,
  514.  
  515.           MUIA_NListview_NList, LI_Text = NListObject,
  516.             MUIA_ObjectID, MAKE_ID('N','L','0','1'),
  517.             MUIA_NList_DefaultObjectOnClick, TRUE,
  518.             MUIA_NList_MultiSelect, MUIV_NList_MultiSelect_None,
  519.             MUIA_NList_DisplayHook2, &DisplayLI_TextHook,
  520.             MUIA_NList_CompareHook2, &CompareLI_TextHook,
  521.             MUIA_NList_ConstructHook2, &ConstructLI_TextHook,
  522.             MUIA_NList_DestructHook2, &DestructLI_TextHook,
  523.             MUIA_NList_Format, "BAR W=-1,BAR W=-1,BAR",
  524.             MUIA_NList_SourceArray, MainTextArray,
  525.             MUIA_NList_AutoVisible, TRUE,
  526.             MUIA_NList_TitleSeparator, TRUE,
  527.             MUIA_NList_Title, TRUE,
  528.             MUIA_NList_EntryValueDependent, TRUE,
  529.             MUIA_NList_MinColSortable, 0,
  530.             MUIA_NList_Imports, MUIV_NList_Imports_All,
  531.             MUIA_NList_Exports, MUIV_NList_Exports_All,
  532.           End,
  533.           MUIA_ShortHelp, "The nice multicolumn\ndraggable list\nwith char selection\npossibility :)",
  534.         End,
  535.       End,
  536.     End,
  537.     SubWindow, WIN_2 = WindowObject,
  538.       MUIA_Window_Title, "NList-Demo 1996-1998 Win 2",
  539.       MUIA_Window_ID   , MAKE_ID('W','I','N','2'),
  540.       MUIA_Window_UseBottomBorderScroller, TRUE,
  541.       WindowContents, VGroup,
  542.         Child, NFloattext(MainTextString2),
  543.         Child, BalanceObject, End,
  544.         Child, VGroup,
  545.           MUIA_Group_VertSpacing, 1,
  546.           Child, LV_Text2 = NListviewObject,
  547.             MUIA_CycleChain, 1,
  548.             MUIA_NListview_Horiz_ScrollBar, MUIV_NListview_HSB_None,
  549.             MUIA_NListview_NList, LI_Text2 = NListObject,
  550.               MUIA_NList_DefaultObjectOnClick, TRUE,
  551.               MUIA_NList_ConstructHook, MUIV_NList_ConstructHook_String,
  552.               MUIA_NList_DestructHook, MUIV_NList_DestructHook_String,
  553.               MUIA_NList_SourceString, MainTextString,
  554.             End,
  555.             MUIA_ShortHelp, "The 2nd list",
  556.           End,
  557.           Child, ST_string = StringObject,
  558.             MUIA_CycleChain, 1,
  559.             StringFrame,
  560.           End,
  561.           Child, PR_Horiz = ScrollbarObject,
  562.             MUIA_Group_Horiz, TRUE,
  563.             MUIA_Prop_UseWinBorder,MUIV_Prop_UseWinBorder_Bottom,
  564.           End,
  565.         End,
  566.       End,
  567.     End,
  568.   End;
  569.  
  570.   if(!APP_Main) fail(APP_Main,"Failed to create Application.");
  571.  
  572.  
  573.   /* ********** MAIN LIST NOTIFIES ********** */
  574.  
  575.   DoMethod(LI_Text, MUIM_Notify, MUIA_NList_TitleClick,MUIV_EveryTime,
  576.     LI_Text, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_Both);
  577.   DoMethod(LI_Text, MUIM_Notify, MUIA_NList_TitleClick2,MUIV_EveryTime,
  578.     LI_Text, 4, MUIM_NList_Sort3, MUIV_TriggerValue, MUIV_NList_SortTypeAdd_2Values, MUIV_NList_Sort3_SortType_2);
  579.   DoMethod(LI_Text, MUIM_Notify, MUIA_NList_SortType,MUIV_EveryTime,
  580.     LI_Text, 3, MUIM_Set,MUIA_NList_TitleMark,MUIV_TriggerValue);
  581.   DoMethod(LI_Text, MUIM_Notify, MUIA_NList_SortType2,MUIV_EveryTime,
  582.     LI_Text, 3, MUIM_Set,MUIA_NList_TitleMark2,MUIV_TriggerValue);
  583.  
  584.  
  585.   /* ********** MAIN LIST IMAGES ********** */
  586.  
  587.   DoMethod(LI_Text,MUIM_NList_UseImage,BM_img,0,0);
  588.   DoMethod(LI_Text,MUIM_NList_UseImage,BM_img2,1,0);
  589.  
  590.   DoMethod(LI_Text,MUIM_NList_UseImage,NImageObject,2,~0L);
  591.  
  592.  
  593.   /* ********** BUTTONS NOTIFIES ********** */
  594.  
  595.   DoMethod(BT_TitleOn, MUIM_Notify, MUIA_Pressed,FALSE,
  596.     LI_Text, 3, MUIM_Set,MUIA_NList_Title,"\033cThis is that list title !   :-)");
  597.   DoMethod(BT_TitleOff, MUIM_Notify, MUIA_Pressed,FALSE,
  598.     LI_Text, 3, MUIM_Set,MUIA_NList_Title,NULL);
  599.   DoMethod(BT_NoMulti, MUIM_Notify, MUIA_Pressed,FALSE,
  600.     LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_None);
  601.   DoMethod(BT_Multidef, MUIM_Notify, MUIA_Pressed,FALSE,
  602.     LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Default);
  603.   DoMethod(BT_Multi, MUIM_Notify, MUIA_Pressed,FALSE,
  604.     LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Shifted);
  605.   DoMethod(BT_AllMulti, MUIM_Notify, MUIA_Pressed,FALSE,
  606.     LI_Text, 3, MUIM_Set,MUIA_NList_MultiSelect,MUIV_NList_MultiSelect_Always);
  607.   DoMethod(BT_InputOn, MUIM_Notify, MUIA_Pressed,FALSE,
  608.     LI_Text, 3, MUIM_Set,MUIA_NList_Input,TRUE);
  609.   DoMethod(BT_InputOff, MUIM_Notify, MUIA_Pressed,FALSE,
  610.     LI_Text, 3, MUIM_Set,MUIA_NList_Input,FALSE);
  611.   DoMethod(BT_DragSortOn, MUIM_Notify, MUIA_Pressed,FALSE,
  612.     LI_Text, 3, MUIM_Set,MUIA_NList_DragSortable,TRUE);
  613.   DoMethod(BT_DragSortOff, MUIM_Notify, MUIA_Pressed,FALSE,
  614.     LI_Text, 3, MUIM_Set,MUIA_NList_DragSortable,FALSE);
  615.   DoMethod(BT_RemAct, MUIM_Notify, MUIA_Pressed,FALSE,
  616.     LI_Text, 2, MUIM_NList_Remove,MUIV_NList_Remove_Active);
  617.   DoMethod(BT_RemSel, MUIM_Notify, MUIA_Pressed,FALSE,
  618.     LI_Text, 2, MUIM_NList_Remove,MUIV_NList_Remove_Selected);
  619.   DoMethod(BT_Clear, MUIM_Notify, MUIA_Pressed,FALSE,
  620.     LI_Text, 1, MUIM_NList_Clear);
  621.   DoMethod(BT_Add, MUIM_Notify, MUIA_Pressed,FALSE,
  622.     LI_Text, 4, MUIM_NList_Insert,MainTextArray,15,MUIV_NList_Insert_Bottom);
  623.   DoMethod(BT_Sort, MUIM_Notify, MUIA_Pressed,FALSE,
  624.     LI_Text, 1, MUIM_NList_Sort);
  625.   DoMethod(BT_SelLine, MUIM_Notify, MUIA_Pressed,FALSE,
  626.     LI_Text, 3, MUIM_Set,MUIA_NList_TypeSelect,MUIV_NList_TypeSelect_Line);
  627.   DoMethod(BT_SelChar, MUIM_Notify, MUIA_Pressed,FALSE,
  628.     LI_Text, 3, MUIM_Set,MUIA_NList_TypeSelect,MUIV_NList_TypeSelect_Char);
  629.   DoMethod(BT_OpenWin2, MUIM_Notify, MUIA_Pressed,FALSE,
  630.     WIN_2, 3, MUIM_Set,MUIA_Window_Open,TRUE);
  631.  
  632.  
  633.   /* ********** WINDOW1 KEYS NOTIFIES ********** */
  634.  
  635.   DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f2",
  636.     LI_Text, 4,MUIM_NList_CopyTo,MUIV_NList_CopyTo_Selected,"PRT:",&result,NULL);
  637.   DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f3",
  638.     LI_Text, 4,MUIM_NList_CopyTo,MUIV_NList_CopyTo_All,"RAM:tmp.txt",&result,NULL);
  639.   DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f4",
  640.     LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_Selected,0L,NULL,NULL);
  641.   DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f5",
  642.     LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_Active,0L,NULL,NULL);
  643.   DoMethod(WIN_Main,MUIM_Notify, MUIA_Window_InputEvent, "f6",
  644.     LI_Text, 4,MUIM_NList_CopyToClip,MUIV_NList_CopyToClip_All,0L,NULL,NULL);
  645.  
  646.  
  647.   /* ********** WINDOW2 LIST NOTIFIES ********** */
  648.  
  649.   DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_ButtonClick, 1,
  650.     APP_Main, 6, MUIM_Application_PushMethod,
  651.     WIN_2, 3, MUIM_Set,MUIA_Window_Open,FALSE);
  652.  
  653.   DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_ButtonClick, 2,
  654.     LI_Text, 1, MUIM_NList_Clear);
  655.  
  656.  
  657.   DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_Entries,MUIV_EveryTime,
  658.     PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_Entries,MUIV_TriggerValue);
  659.   DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_Visible,MUIV_EveryTime,
  660.     PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_Visible,MUIV_TriggerValue);
  661.   DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_Horiz_First,MUIV_EveryTime,
  662.     PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_First,MUIV_TriggerValue);
  663.   DoMethod(PR_Horiz, MUIM_Notify, MUIA_Prop_First,MUIV_EveryTime,
  664.     LI_Text2, 3, MUIM_NoNotifySet,MUIA_NList_Horiz_First,MUIV_TriggerValue);
  665.   DoMethod(LI_Text2, MUIM_Notify, MUIA_NList_HorizDeltaFactor,MUIV_EveryTime,
  666.     PR_Horiz, 3, MUIM_NoNotifySet,MUIA_Prop_DeltaFactor,MUIV_TriggerValue);
  667.  
  668.   set(ST_string, MUIA_String_AttachedList, LI_Text2);
  669.   DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_SelectChange,TRUE,APP_Main,2,MUIM_Application_ReturnID,ID_LIST2_ACTIVE);
  670.   DoMethod(LI_Text2,MUIM_Notify,MUIA_NList_Active,MUIV_EveryTime,APP_Main,2,MUIM_Application_ReturnID,ID_LIST2_ACTIVE);
  671.   set(LI_Text2, MUIA_NList_Active, 2);
  672.  
  673.  
  674.   /* ********** WINDOW2 LIST IMAGES ********** */
  675.  
  676.   DoMethod(LI_Text2,MUIM_NList_UseImage,BM_img,0,0);
  677.   DoMethod(LI_Text2,MUIM_NList_UseImage,BM_img2,1,0);
  678.  
  679.   DoMethod(LI_Text2,MUIM_NList_UseImage,SimpleButtonTiny("Click me to close"),2,~0L);
  680.   DoMethod(LI_Text2,MUIM_NList_UseImage,SimpleButtonTiny("Clear main list"),3,~0L);
  681.  
  682.  
  683.   /* ********** WINDOW2 NOTIFIES ********** */
  684.  
  685.   DoMethod(WIN_Main,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  686.     APP_Main, 5, MUIM_Application_PushMethod,
  687.     APP_Main,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  688.  
  689.   DoMethod(WIN_2,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  690.     APP_Main, 6, MUIM_Application_PushMethod,
  691.     WIN_2, 3, MUIM_Set,MUIA_Window_Open,FALSE);
  692.  
  693.   set(WIN_Main, MUIA_Window_DefaultObject, LV_Text);
  694.   set(WIN_Main, MUIA_Window_ActiveObject, LV_Text);
  695.   set(WIN_2, MUIA_Window_ActiveObject, ST_string);
  696.   set(WIN_2, MUIA_Window_DefaultObject, LV_Text2);
  697.  
  698.  
  699.   /* ************************************** */
  700.  
  701.   DoMethod(APP_Main,MUIM_Application_Load,MUIV_Application_Load_ENVARC);
  702.  
  703.   /* *** If need to be sorted, sort then restore the active and first *** */
  704.   /* ***            which were set in the Application_Load            *** */
  705.   { LONG active,first,sorttype;
  706.     get(LI_Text,MUIA_NList_SortType,&sorttype);
  707.     if (sorttype != MUIV_NList_SortType_None)
  708.     { get(LI_Text,MUIA_NList_Active,&active);
  709.       get(LI_Text,MUIA_NList_First,&first);
  710.       DoMethod(LI_Text, MUIM_NList_Sort);
  711.       set(LI_Text,MUIA_NList_Active,active);
  712.       set(LI_Text,MUIA_NList_First,first);
  713.     }
  714.   }
  715.  
  716.   set(WIN_2,MUIA_Window_Open,TRUE);
  717.   set(WIN_Main,MUIA_Window_Open,TRUE);
  718.  
  719.   get(WIN_Main,MUIA_Window_Open,&win_opened);
  720.   if (win_opened)
  721.   { ULONG id,sigs = 0;
  722.     char *line;
  723.  
  724.     while ((id = DoMethod(APP_Main,MUIM_Application_NewInput,&sigs)) != MUIV_Application_ReturnID_Quit)
  725.     {
  726.       if (id == ID_LIST2_ACTIVE)
  727.       { DoMethod(LI_Text2, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &line);
  728.         set(ST_string, MUIA_String_Contents, line);
  729.         set(WIN_2, MUIA_Window_ActiveObject, ST_string);
  730.       }
  731.       if (sigs)
  732.       { sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  733.         if (sigs & SIGBREAKF_CTRL_C) break;
  734.       }
  735.     }
  736.   }
  737.   else
  738.     printf("failed to open main window !\n");
  739.  
  740.   DoMethod(APP_Main,MUIM_Application_Save,MUIV_Application_Save_ENVARC);
  741.  
  742.   set(WIN_2,MUIA_Window_Open,FALSE);
  743.   set(WIN_Main,MUIA_Window_Open,FALSE);
  744.  
  745.   DoMethod(LI_Text,MUIM_NList_UseImage,NULL,-1,0);
  746.   DoMethod(LI_Text2,MUIM_NList_UseImage,NULL,-1,0);
  747.  
  748.   fail(APP_Main,NULL);
  749. }
  750.  
  751.